startForeground
open fun startForeground(@NonNull service: @NonNull Service, id: Int, @NonNull notification: @NonNull Notification, foregroundServiceType: Int)(source)
startForeground with the third parameter foregroundServiceType was added in Q.
Before SDK Version Q, this method call should call startForeground without the foregroundServiceType parameter.
Beginning with SDK Version Q, the allowed foregroundServiceType are:
- FOREGROUND_SERVICE_TYPE_MANIFEST
- FOREGROUND_SERVICE_TYPE_NONE
- FOREGROUND_SERVICE_TYPE_DATA_SYNC
- FOREGROUND_SERVICE_TYPE_MEDIA_PLAYBACK
- FOREGROUND_SERVICE_TYPE_PHONE_CALL
- FOREGROUND_SERVICE_TYPE_LOCATION
- FOREGROUND_SERVICE_TYPE_CONNECTED_DEVICE
- FOREGROUND_SERVICE_TYPE_MEDIA_PROJECTION
- FOREGROUND_SERVICE_TYPE_CAMERA
- FOREGROUND_SERVICE_TYPE_MICROPHONE
Beginning with SDK Version UPSIDE_DOWN_CAKE, apps targeting SDK Version UPSIDE_DOWN_CAKE is not allowed to use FOREGROUND_SERVICE_TYPE_NONE. The allowed foregroundServiceType are:
- FOREGROUND_SERVICE_TYPE_MANIFEST
- FOREGROUND_SERVICE_TYPE_DATA_SYNC
- FOREGROUND_SERVICE_TYPE_MEDIA_PLAYBACK
- FOREGROUND_SERVICE_TYPE_PHONE_CALL
- FOREGROUND_SERVICE_TYPE_LOCATION
- FOREGROUND_SERVICE_TYPE_CONNECTED_DEVICE
- FOREGROUND_SERVICE_TYPE_MEDIA_PROJECTION
- FOREGROUND_SERVICE_TYPE_CAMERA
- FOREGROUND_SERVICE_TYPE_MICROPHONE
- FOREGROUND_SERVICE_TYPE_HEALTH
- FOREGROUND_SERVICE_TYPE_REMOTE_MESSAGING
- FOREGROUND_SERVICE_TYPE_SYSTEM_EXEMPTED
- FOREGROUND_SERVICE_TYPE_SHORT_SERVICE
- FOREGROUND_SERVICE_TYPE_SPECIAL_USE